'use strict'
const db = uniCloud.database()
exports.main = async (event, context) => {
	const {
		mobile
	} = event

	// 先查询是否存在该手机号
	const userInfo = await db
		.collection('school_user_info')
		.where({
			mobile: mobile,
		}).limit(1)
		.get()

	// 判断是否已存在
	if (userInfo.data && userInfo.data.length > 0) {
		return {
			code: 100,
			data: userInfo.data[0]
		}
	}

	// 如果不存在,注册用户
	return {
		code: -1,
		mes: "账号未注册"
	}
}